package cz.techi;


import java.text.DateFormatSymbols;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

public class Subject {
	
	public static final int TYPE_LECTURE = 1;
	public static final int TYPE_SEMINAR = 2;
	public static final int TYPE_UNKNOWN = 3;
	
	
	public String ident;
	public String name;
	public int hour;
	public String from;
	public String to;
	public String day;
	public String teacher;
	public String room;
	public String type;
	
	public String getIdent()
	{
		return ident;
	}
	
	public String getName()
	{
		return name;
	}
	
	public int getType()
	{
		if (type.equalsIgnoreCase("lecture"))
		{
			return TYPE_LECTURE;
		}
		
		else if (type.equalsIgnoreCase("seminar"))
		{
			return TYPE_SEMINAR;
		}
		
		return TYPE_UNKNOWN;		
	}
	
	public int getDay()
	{
		if (day.equalsIgnoreCase("mon"))
		{
			return Calendar.MONDAY;
		}
		else if(day.equalsIgnoreCase("tue"))
		{
			return Calendar.TUESDAY;
		}
		else if(day.equalsIgnoreCase("wed"))
		{
			return Calendar.WEDNESDAY;
		}
		else if(day.equalsIgnoreCase("thu"))
		{
			return Calendar.THURSDAY;
		}
		else if(day.equalsIgnoreCase("fri"))
		{
			return Calendar.FRIDAY;
		}
		
		return -1;
	}
	
	public Date getStart()
	{
		// example 09:15
		
		Date date = new Date();
		date.setHours(Integer.parseInt(from.substring(0, 2)));
		date.setMinutes(Integer.parseInt(from.substring(3, 5)));
		date.setSeconds(0);
		
	
		return date;
	}
	
	public Date getEnd()
	{
		
		Date date = new Date();
		date.setHours(Integer.parseInt(to.substring(0, 2)));
		date.setMinutes(Integer.parseInt(to.substring(3, 5)));
		date.setSeconds(0);
		
		return date;
	}
	
	public String getLocalizedDay()
	{
		DateFormatSymbols symbols = new DateFormatSymbols(Locale.getDefault());
		
		String[] dayNames = symbols.getWeekdays();

		return dayNames[this.getDay()];
	}
}
